package com.example.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.entity.DeliveryOrder;
import com.example.demo.entity.DispatchInfo;
import com.example.demo.entity.PurchaseOrder;
import com.example.demo.service.DispatchInfoService;
import com.example.demo.mapper.DispatchInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 18364
* @description 针对表【dispatch_info】的数据库操作Service实现
* @createDate 2025-01-08 15:34:28
*/
@Service
public class DispatchInfoServiceImpl extends ServiceImpl<DispatchInfoMapper, DispatchInfo>
    implements DispatchInfoService{
    @Autowired
    DispatchInfoMapper dispatchInfoMapper;

    @Override
    public DispatchInfo select(String logisticsNumber) {
        QueryWrapper<DispatchInfo> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("logisticsNumber",logisticsNumber);
        queryWrapper.orderByDesc("id");
        List<DispatchInfo> resultList = dispatchInfoMapper.selectList(queryWrapper);
        if (!resultList.isEmpty()) {
            return resultList.get(0); // 这里返回结果列表的第一条记录
        } else {
            return null;
        }
    }

    @Override
    public Integer delete(String userId, String trainingId, String logisticsNumber) {
        QueryWrapper<DispatchInfo> queryWrapper=new QueryWrapper<>();
        if(logisticsNumber!=null){
            queryWrapper.eq("logisticsNumber",logisticsNumber);
        }
        return dispatchInfoMapper.delete(queryWrapper);
    }
}




